/**
 * Created by Administrator on 2016/4/11.
 */
//    引用dao层公共部分
//var dao = require("./execsql.js");

//注册 往user表插入数据 POST 方法
exports.registSql = function (req,res) {
    //getTime()  	返回 1970 年 1 月 1 日至今的毫秒数。 创建userid
    var userId = new Date().getTime();
    //从post 中的request 取数据 插入 表中.
    //var userName = req.body.userName;
    var userName = "jaja";
    var userPhone = req.body.userPhone;
    var userPwd = req.body.userPwd;

    var sql = "INSERT INTO hc_user (user_id,phone,pwd,user_name) VALUES("+userId+",'"+userPhone+"','"+userPwd+"','"+userName+"');";
    //调用封装好了的数据连接池.
    dao.poolGetConnection(sql,res);

};


//验证此手机号码在数据库中是否存在
exports.shoji=function (req,res){
    var phone=req.body.phone;
    var sql="SELECT * FROM hc_user WHERE phone='"+phone+"'";
    dao.poolGetConnection(sql,res);
};

//登录 在user表查询数据 POST 方法
exports.loginSql = function (req,res) {
    var userPhone = req.body.phone;
    var userPwd = req.body.pwd;
    //console.log(userPhone);
    //console.log(userPwd);

    var sql ="SELECT * FROM hc_user WHERE phone='"+userPhone+"'AND pwd='"+userPwd+"'";
    dao.poolGetConnection(sql,res);
};